package com.bqjr.xms.controller;

import com.bqjr.xms.modle.ProviderContract;
import com.bqjr.xms.service.ProviderContractService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description: ProviderContractController.
 * 作用：
 * ① 测试服务实例的相关内容
 * ② 为后来的服务做提供
 *
 * Created by XHZ on 2017/8/7.
 */
@RestController
@RequestMapping("/contract")
@RefreshScope
public class ProviderContractController {
    private static final Logger logger = LoggerFactory.getLogger(ProviderContractController.class);
    @Autowired
    private ProviderContractService providerContractService;

    @Value("${profile}")
    private String profile;

    @GetMapping("/hello")
    public String hello() {
        return this.profile;
    }

    /**
     * 注：@GetMapping("/{id}")是spring 4.3的新注解等价于：
     * @RequestMapping(value = "/id", method = RequestMethod.GET)
     * 类似的注解还有@PostMapping等等
     * @param id
     * @return user信息
     */
    @GetMapping("/{id}")
    public ProviderContract findById(@PathVariable Long id) {
        logger.info("根据id查询用户信息");
        return this.providerContractService.findOne(id);
    }

}
